interface PersonRawState {
  // 必须属性
  name: string;
  age: number;
  // 可选属性
  weight?: string;
  // 只读属性
  readonly code: number;
  // 其他属性
  [propsName: string]: any;
}

/**************** 1.描述 json ***********************/
export const o1: PersonRawState = {
  name: "张三",
  age: 18,
  weight: "80kg",
  code: 100,
};
export const o2: PersonRawState = {
  name: "张三",
  age: 18,
  code: 110,

  qwer: 123,
  uu: true,
  arr: [, 1, 2, 3, 4],
};

/**************** 2.函数类型 ***********************/
interface FnType {
  (x: number, y: number): number;
}

// 函数表达式
export const fnn: FnType = function (x: number, y: number): number {
  return x + y;
};

/** 算法 */
// 封装求和函数，实现不定参数的求和
/* 刘红 */
function sum(...arr: number[]): number {
  let count: number = 0;

  for (let i = 0; i < arr.length /* 赵露 */; i++) {
        count += arr[i];
  }

  return count;
}

const result = sum(1, 2, 3, 4, 5);
const result1 = sum(1, 2, 3, 4, 5,5,6,7,8,9);

// 封装函数， 接受字符串类型的数组，返回数组的最长的字符串的信息
function findLongStrInfo(arr: string[]): number {
  let count = 0;
  arr.forEach(str => {
    if(count <  str.length) {
      count = str.length
    }
  })

  return count
}
const s = findLongStrInfo(['aaaaa', "jhgfdsasdfgh", "ytre"])


/**************** 3.可索引的类型 ***********************/
interface ArrState {
  [propsNama: number]: string | number
}


export const arr1: number[] = [1,2,3,4]
export const arr2: ArrState = ['a', 'b', 'c', 1,2,3,54]

/**************** 4.类 类型 ***********************/

// 见类文件






